#ifndef _TREEDIRECTORYINTERFACE_H_
#define _TREEDIRECTORYINTERFACE_H_

#include <QLineEdit>
#include <QPushButton>
#include <QMenu>
#include <QScreen>
#include <QScrollArea>
#include <QMap>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMessageBox>



#include "TreeItemInfo.h"
#include "WavePlotInterface.h"

class TreeDirectoryInterface : public QWidget
{
    Q_OBJECT

public:
    explicit TreeDirectoryInterface(QWidget* treeWidget, WavePlotInterface &wavePlotInf, QMap<int, QString> &electrodeMap, QWidget *parent = nullptr);
    ~TreeDirectoryInterface();
    void initTree();
    void search();
    void initMap();
/*
     *      创建根节点
     * text     根节点名字
     * pid      根节点ID
     * return   返回该节点ID,如果无父节点默认值为NULL
     */
    QString CreateRootLeafNode(QString name, QString pid = NULL);
    /*
     *      创建子节点(实体对象节点)
     * info     树形节点信息实体
     * pid      子节点ID
     * return   返回该节点ID
     */
    bool CreateChildLeafNode(TreeItemInfo* info, QString pid = NULL);




signals:
	void sig_itemCheckChange(QString str, bool);
	void sig_itemDoubliClicked(QString str);
	void sig_itemMenuClick(QString str);

public slots:
    void menuAction(QAction* action);
    void tree_itemPressed(QTreeWidgetItem* item, int column);
    void tree_itemDoubleClicked(const QModelIndex& index);
    void tree_itemChanged(QTreeWidgetItem* item, int column);
    void serchTextChanged();
    void btn_expandingTreeNode(bool);




private:
    WavePlotInterface &fri_wavePlotInf;
    QMap<int, QString> &electrodeNameMap;

    QWidget* m_treeWidget = nullptr;

    QPushButton* btn_serchItem = nullptr;
    QLineEdit* edit_serchItem = nullptr;

    QTreeWidget* _leftTree = nullptr;


    QTreeWidgetItem* rootTreeItem = nullptr;
    QTreeWidgetItem* LeafTreeItem = nullptr;
    QScrollArea* scroll = nullptr;
    int index = 0;
    TreeItemInfo* info = nullptr;
    QMap<QString, QTreeWidgetItem*> _treeItemMap;
    QMap<QString, QTreeWidgetItem*> _treeNameMap;    //叶子节点名字

    // QMap<int, DevStationData* > devMap;
    QMap<int, std::shared_ptr<DevStationData>> devMap;
    

    /*QMap中
    clear功能:虽清除但key值还在
    remove:删除，key值也消失
    key和value一损俱损*/

    //当前显示器分辨率和1920*1080分辨率的比例
    // double _widthScale;
    // double _hightScale;
    QMenu* _menu = nullptr;
	// QMap<QString, DevStationData*> _devCodeMap;
};








#endif // !_TREEDIRECTORYINTERFACE_H_